<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

<script>
// 混合模式（组合模式）创建对象
// 通过构造函数添加对象不同的属性
// 通过原型添加对象共享的方法

function Human(n,s){
    this.name = n;
    this.sex = s;
}
Human.prototype.type = '人类';
Human.prototype.say = function (){
    console.log( 'hi' );
}
var person1 = new Human('老王','男');
var person2 = new Human('老宋','男');
console.log( person1.name );
console.log( person2.name );
person1.say();
person2.say();

</script>
</body>
</html>